package com.jd.org.dto;


import com.jd.org.domain.Employee;
import com.jd.org.domain.Shop;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.Date;

/**
 * @description: 店铺信息表
 * @author 小林同学
 * @date 2023/2/28 19:37
 * @version 1.0
 */
@Data
public class ShopSettlementDto {
    @NotBlank(message = "店铺名不能为空")
    private String name;
    @NotBlank(message = "座机号不能为空")
    private String tel;
    @NotBlank(message = "地址不能为空")
    private String address;
    private String logo;
    // 管理员是存在员工表
    @Valid
    private ShopAdminDto admin;

    public Shop getShop(){
        return Shop
                .builder()
                .name(this.name)
                .address(this.address)
                .logo(this.logo)
                .registerTime(new Date())
                .state(0)
                .tel(this.tel)
                .build();
    }

    public Employee getEmployee(){
        return Employee
                .builder()
                .username(this.admin.getUsername())
                .phone(this.admin.getPhone())
                .email(this.admin.getEmail())
                .password(this.admin.getPassword())
                .state(1)
                .build();

    }



}
